package com.sangjie.souyidai.service;

import java.util.Timer;
import java.util.TimerTask;

import com.sangjie.souyidai.https.Souyidai;
import com.sangjie.souyidai.https.XiangShang;

public class SignService {
	
	// 比一天小一点，防止每天时间都一样
	private static final int ONE_DAY = 24 * 3600 * 1000 - 2739;
	
	Timer timer;
	
	public SignService() {
		timer = new Timer();
	}

	public void signIn() {
		
		timer.schedule(new TimerTask() {

			@Override
			public void run() {
				Souyidai.signIn();
				XiangShang.signIn();
			}
		}, 0, ONE_DAY);
	}
	
	public void cancelSign() {
		if (timer != null) {
			timer.cancel();
		}
	}
	
}
